package com.xjy.headfirst.观察者模式;

/**
 * @author :辛纪元
 * @date :2022-06-08 22:02
 * @description:观察者设计模式最终实现
 */

public class Realize {

    public static void main(String[] args) {
        WeacherData weacherData = new WeacherData();

        CurrentConditionDisplay currentConditionDisplay = new CurrentConditionDisplay(weacherData);
        SecoundConditionDisplay secoundConditionDisplay = new SecoundConditionDisplay(weacherData);
        System.out.println("观察者还剩下"+weacherData.getList());
        weacherData.setMeasurements("xjy",23);

        weacherData.deleteObserver(secoundConditionDisplay);
        weacherData.deleteObserver(currentConditionDisplay);
        System.out.println("观察者还剩下"+weacherData.getList());
        weacherData.setMeasurements("jjj",111);
    }

}
